<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改蚌埠商场信息')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<style>
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }

</style>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="dv">
    <form class="form-horizontal m" id="form-businessbb-edit" AUTOCOMPLETE="OFF">
        <input type="hidden" name="id" th:value="${data.id}">
        <input type="hidden" name="countIncome" th:value="${data.countIncome}">
        <input type="hidden" name="otherIncome" th:value="${data.otherIncome}">
        <input type="hidden" name="fixedCost" th:value="${data.fixedCost}">
        <input type="hidden" name="variableCost" th:value="${data.variableCost}">
        <input type="hidden" name="profit" th:value="${data.profit}">
        <input type="hidden" id="fillDays" th:value="${data.fillDay}">
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">选择日：</label>
                    <div class="col-sm-8">
                        <select id="fillDay" name="fillDay" class="form-control noselect2">
                            <option value="">请选择</option>

                        </select>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">日客流：</label>
                    <div class="col-sm-8">
                        <input id="dayPassengerFlow" name="dayPassengerFlow" class="form-control" type="number"
                               th:value="${data.dayPassengerFlow}" placeholder="请输入日客流" required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">联营：</label>
                    <div class="col-sm-8">
                        <input id="commonIncome" name="commonIncome" class="form-control" type="number"
                               th:value="${data.commonIncome}" placeholder="请输入联营" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">房租：</label>
                    <div class="col-sm-8">
                        <input id="rent" name="rent" class="form-control" type="number" placeholder="请输入房租"
                               th:value="${data.rent}" required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">物业费：</label>
                    <div class="col-sm-8">
                        <input id="property" name="property" class="form-control" type="number"
                               th:value="${data.property}" placeholder="请输入物业费" required/>
                    </div>
                </div>
            </div>
        </div>

        <h4 class="form-header h4" id="otherIncome">其他收入（0）元</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">广告位：</label>
                    <div class="col-sm-8">
                        <input id="advertisement" name="advertisement" class="form-control" type="number"
                               th:value="${data.advertisement}" placeholder="请输入广告位" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">多经点位：</label>
                    <div class="col-sm-8">
                        <input id="multiple" name="multiple" class="form-control" type="number"
                               th:value="${data.multiple}" placeholder="请输入多经点位"
                               required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">特卖：</label>
                    <div class="col-sm-8">
                        <input id="restaurant" name="restaurant" class="form-control" type="number"
                               th:value="${data.restaurant}" placeholder="请输入特卖收入" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label" style="white-space: nowrap">购物卡手续费：</label>
                    <div class="col-sm-8">
                        <input id="procedures" name="procedures" class="form-control" type="number"
                               th:value="${data.procedures}" placeholder="请输入购物卡手续费"
                               required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">其他：</label>
                    <div class="col-sm-8">
                        <input id="businessOther" name="businessOther" class="form-control" type="number"
                               th:value="${data.businessOther}" placeholder="请输入其他" required/>
                    </div>
                </div>

            </div>
        </div>

        <h4 class="form-header h4" id="countIncome" style="text-align: right;font-weight: 700;">营业总收入（0）元</h4>
        <h4 class="form-header h4" id="fixedCost">固定费用（0）元</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">人力成本：</label>
                    <div class="col-sm-8">
                        <input id="laborCost" name="laborCost" class="form-control" type="number"
                               th:value="${data.laborCost}" placeholder="请输入人力成本" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">租赁费：</label>
                    <div class="col-sm-8">
                        <input id="rental" name="rental" class="form-control" type="number" placeholder="请输入租赁费"
                               th:value="${data.rental}" required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">物管费：</label>
                    <div class="col-sm-8">
                        <input id="propertyManagement" name="propertyManagement" class="form-control" type="number"
                               th:value="${data.propertyManagement}" placeholder="请输入物管费" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">低耗摊销：</label>
                    <div class="col-sm-8">
                        <input id="commonBear" name="commonBear" class="form-control" type="number"
                               th:value="${data.commonBear}" placeholder="请输入低耗摊销"
                               required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">资产折旧：</label>
                    <div class="col-sm-8">
                        <input id="assets" name="assets" class="form-control" type="number"
                               th:value="${data.assets}" placeholder="请输入资产折旧" required/>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4" id="variableCost">变动费用（0）元</h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">成本：</label>
                    <div class="col-sm-8">
                        <input id="cost" name="cost" class="form-control" type="number"
                               th:value="${data.cost}" placeholder="请输入成本" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">水电气能耗：</label>
                    <div class="col-sm-8">
                        <input id="waterAndElectricity" name="waterAndElectricity" class="form-control" type="number"
                               th:value="${data.waterAndElectricity}" placeholder="水电气能耗"
                               required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">广宣费：</label>
                    <div class="col-sm-8">
                        <input id="propaganda" name="propaganda" class="form-control" type="number"
                               th:value="${data.propaganda}" placeholder="请输入广宣费" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">其他：</label>
                    <div class="col-sm-8">
                        <input id="other" name="other" class="form-control" type="number"
                               th:value="${data.other}" placeholder="请输入其他"
                               required/>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4" id="profit" style="text-align: right;font-weight: 700;">利润（0）</h4>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>

<script type="text/javascript">
    var prefix = ctx + 'BusinessBb';
    var countIncome;//营业总收入
    var otherIncome;//其他收入
    var fixedCost;//固定费用
    var variableCost;//变动费用
    var profit;//利润th:

    $(function () {
        for (var i = 1; i <= 31; i++) {
            $("#fillDay").append("<option value='" + i + "'>" + i + "日" + "</option>");
            if (Number($("#fillDays").val()) == i) {
                $("#fillDay").find("option:contains('" + i + "日')").attr("selected", true);
            }
        }
        calculation();
        $("#otherIncome").text("其他收入（" + $("input[name='otherIncome']").val() + "）元");
        $("#countIncome").text("营业总收入（" + $("input[name='countIncome']").val() + "）元");
        $("#fixedCost").text("固定费用（" + $("input[name='fixedCost']").val() + "）元");
        $("#variableCost").text("变动费用（" + $("input[name='variableCost']").val() + "）元");
        $("#profit").text("利润（" + $("input[name='profit']").val() + "）");

    });

    $("input").change(function () {
        calculation();
    });

    function calculation() {
        otherIncome = (Number($("#advertisement").val()) + Number($("#multiple").val()) + Number($("#restaurant").val()) + Number($("#procedures").val()) + Number($("#businessOther").val())).toFixed(2);
        $("#otherIncome").text("其他收入（" + otherIncome + "）元");
        countIncome = (Number($("#commonIncome").val()) + Number($("#rent").val()) + Number($("#property").val()) + Number(otherIncome)).toFixed(2);
        $("#countIncome").text("营业总收入（" + countIncome + "）元");
        fixedCost = (Number($("#laborCost").val()) + Number($("#rental").val()) + Number($("#propertyManagement").val()) + Number($("#commonBear").val()) + Number($("#assets").val())).toFixed(2);
        $("#fixedCost").text("固定费用（" + fixedCost + "）元");
        variableCost = (Number($("#cost").val()) + Number($("#waterAndElectricity").val()) + Number($("#propaganda").val()) + Number($("#other").val())).toFixed(2);
        $("#variableCost").text("变动费用（" + variableCost + "）元");
        profit = (Number(countIncome) - Number(fixedCost) - Number(variableCost)).toFixed(2);
        $("#profit").text("利润（" + profit + "）");
        $("input[name='countIncome']").val(countIncome);
        $("input[name='otherIncome']").val(otherIncome);
        $("input[name='fixedCost']").val(fixedCost);
        $("input[name='variableCost']").val(variableCost);
        $("input[name='profit']").val(profit);
    }

    function submitHandler() {
        if ($.validate.form()) {
            calculation();
            var data = $("#form-businessbb-edit").serializeArray();
            $.operate.save(prefix + "/edit?monthId=" + $("input[name='monthId']").val(), data);
        }
    }


</script>

</body>
</html>